<%@ Page Language="C#" MasterPageFile="~/Admin/Admin.master" AutoEventWireup="true" CodeFile="Area.aspx.cs" Inherits="Admin_Area" Title="Areas Manager" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <span style="font-size: 32pt"><strong>Areas Manager<br />
    </strong></span>
    <br />
    <asp:Label ID="Label1" runat="server" ForeColor="Red"></asp:Label><br />
    <table style="width: 382px">
        <tr>
            <td style="width: 21px">
                Location:</td>
            <td style="width: 100px">
                <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
                </td>
        </tr>
        <tr>
            <td style="width: 21px">
            </td>
            <td style="width: 100px">
                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TextBox1"
                    ErrorMessage="Location cannot be null" Width="174px"></asp:RequiredFieldValidator></td>
        </tr>
        <tr>
            <td colspan="2">
                <asp:Button ID="Button1" runat="server" Text="Add new Area" OnClick="Button1_Click" /></td>
        </tr>
    </table>
    <br />
    <strong><span style="font-size: 16pt">List of areas:</span></strong><br />
    <br />
    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="Pincode"
        DataSourceID="SqlDataSource1" BackColor="White" BorderColor="#999999" BorderStyle="Solid" BorderWidth="1px" CellPadding="3" ForeColor="Black" GridLines="Vertical">
        <Columns>
            <asp:BoundField DataField="Pincode" HeaderText="Pincode" InsertVisible="False" ReadOnly="True"
                SortExpression="Pincode" />
            <asp:BoundField DataField="Location" HeaderText="Location" SortExpression="Location" />
            <asp:CommandField ShowEditButton="True" />
            <asp:CommandField ShowDeleteButton="True" />
        </Columns>
        <FooterStyle BackColor="#CCCCCC" />
        <PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
        <SelectedRowStyle BackColor="#000099" Font-Bold="True" ForeColor="White" />
        <HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" />
        <AlternatingRowStyle BackColor="#CCCCCC" />
    </asp:GridView>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:Con %>"
        DeleteCommand="DELETE FROM [Area] WHERE [Pincode] = @Pincode" InsertCommand="INSERT INTO [Area] ([Location]) VALUES (@Location)"
        SelectCommand="SELECT * FROM [Area]" UpdateCommand="UPDATE [Area] SET [Location] = @Location WHERE [Pincode] = @Pincode">
        <DeleteParameters>
            <asp:Parameter Name="Pincode" Type="Int32" />
        </DeleteParameters>
        <UpdateParameters>
            <asp:Parameter Name="Location" Type="String" />
            <asp:Parameter Name="Pincode" Type="Int32" />
        </UpdateParameters>
        <InsertParameters>
            <asp:Parameter Name="Location" Type="String" />
        </InsertParameters>
    </asp:SqlDataSource>
</asp:Content>

